//
//  SECGestureViewController.swift
//  aj
//
//  Created by leeqb on 1/11/16.
//  Copyright © 2016 powerlee. All rights reserved.
//

import UIKit

class SECGestureViewController: AJBaseViewController, YLSwipeLockViewDelegate {
    var passString: String?
    @IBOutlet weak var titleLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let lockView = YLSwipeLockView(frame: CGRect(x: 30, y: 100, width: SCREEN_WIDTH - 60, height: SCREEN_HEIGHT - 200))
        lockView.delegate = self
        //lockView.backgroundColor = UIColor.blueColor()
        self.view.addSubview(lockView)
    }
    
    func swipeView(swipeView: YLSwipeLockView!, didEndSwipeWithPassword password: String!) -> YLSwipeLockViewState {
        if self.passString == nil {
            self.passString = password
            self.titleLabel.text = "请再次输入"
            return YLSwipeLockViewState.Normal
        } else if self.passString == password {
            self.passString = nil
            CBAlertView.shareInstance().showMsg("图案设置成功")
            self.navigationController?.popToRootViewControllerAnimated(true)
            return YLSwipeLockViewState.Selected
        } else {
            self.passString = nil
            self.titleLabel.text = "请绘制解锁图案"
            CBAlertView.shareInstance().showMsg("图案不一致，请重新输入")
            return YLSwipeLockViewState.Warning
        }
    }

}
